#!/usr/local/bin/perl
# Copyright (c) 2012 ActiveState Software Inc.
# See the file LICENSE.txt for licensing information.


Import(
    'build',
    'buildFlavour',
    'cons',
    'idlExportDir',
    'komodoDevDir',
    'mozBin',
    'mozChromeDir',
    'mozComponentsDir',
    'mozIdlIncludePath',
    'mozSrc',
    'mozVersion',
    'platform',
    'productType',
    'ranRegxpcomStateFileName',
    'sdkDir',
    'unsiloedPythonExe',
);

$cons->Install($idlExportDir, 'koIJSTest.idl');
$cons->BuildAndInstallXpt('koIJSTest.idl');
$cons->InstallXpcomComponent("koJSTest.js",
                             {'@activestate.com/koJSTestService;1' =>
                                '{036dc8b2-7527-469c-828e-50655b56880a}'});
$cons->AddComponentManifestLines("test-registration",
                                 ["category komodo-jstest-paths chrome $komodoDevDir/src/chrome/komodo/content",
                                  "category komodo-jstest-paths test-root $komodoDevDir/test/jstest"]);
$cons->Install("$mozChromeDir/komodo-jstest", "JSTest.jsm");
# Note: InstallRecursive must take absolute paths for input (bug in
#       the InstallRecursive method).
$cons->InstallRecursive("$mozChromeDir/komodo-jstest/mock",
                        cwd()."/test/jstest/mock");
my $buildlistScript = "$mozSrc/mozilla/python/mozbuild/mozbuild/action/buildlist.py";
# Tweak env to point PYTHONPATH at the mozbuild dir.
my %envLocal = $cons->copy();
my $platformPathSep = ($^O eq "MSWin32" ? ";" : ":");
$envLocal{'PYTHONPATH'} = $ENV{'PYTHONPATH'} . "$platformPathSep$mozSrc/mozilla/python/mozbuild";
$consLocal = new cons(ENV => \%envLocal);
$consLocal->Command("$mozChromeDir/komodo-jstest.manifest",
               $buildlistScript,
               # Last command is to fake a touch command using Python.
               qq(
                $unsiloedPythonExe %1 "$mozBin/chrome.manifest" "manifest chrome/komodo-jstest.manifest"
                $unsiloedPythonExe -c "import sys; file(sys.argv[1], 'w')" %0
               ));
$consLocal->Command("komodo-jstest.manifest.landmark",
               "$mozChromeDir/komodo-jstest.manifest",
               $buildlistScript,
               # Last command is to fake a touch command using Python.
               qq(
                $unsiloedPythonExe %2 %1 "resource komodo-jstest komodo-jstest/"
                $unsiloedPythonExe -c "import sys; file(sys.argv[1], 'w')" %0
               ));
